package com.logic.landseaserver.ws;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.logic.common.enums.HttpCodeEnum;
import com.logic.common.util.CommonResultMap;
import com.logic.landseaserver.service.ISurveyService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * Created by Drake on 2017/4/18.
 */
@Path("/survey")
@Api(value="survey")
public class SurveyRest {
	
	@Autowired
	private ISurveyService surveyServiceImpl;
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
    @GET
    @Path("/{surveycode}")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "Get survey by survey code", position = 4)
    public Response retrieveSurveyBySurveyCode(
            @ApiParam(value = "param", required = true) @PathParam("surveycode") String surveyCode) {
        CommonResultMap map = new CommonResultMap();
        try {
            map.setData(surveyServiceImpl.getSurvey(surveyCode));
        } catch (Exception e) {
            logger.error("retrieveSurveyBySurveyCode error.", e);
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }	
    
}
